package hikari.persistence.handlersimpl;

import com.gooddies.wiring.annotations.WiringComponent;
import hikari.objects3d.Basic3dObject;
import hikari.objects3d.NavMesh3dObject;
import hikari.persistence.file.FileSection;
import hikari.persistence.persisthandlers.IPersistantObject3dReadHandler;
import hikari.persistence.persisthandlers.PersistantHandler;
import java.io.IOException;
import org.swig.jirr.ICustomizableTriangleMeshNode;
import org.swig.jirr.ISceneManager;

/**
 * @author Dmitry
 */
@WiringComponent(singleton = true, lazy = true)
@PersistantHandler(sectionName = "navmesh")
public class NavmeshInstantiateHandler implements IPersistantObject3dReadHandler {
    private NavmeshInstantiateHandler() {
    }

    @Override
    public Basic3dObject read(ISceneManager sceneManager, Basic3dObject object, FileSection section) throws IOException {
        ICustomizableTriangleMeshNode node=sceneManager.addICustomizableTriangleMeshNode(sceneManager.getRootSceneNode());
        NavMesh3dObject navmeshObject=new NavMesh3dObject(node);
        return navmeshObject;
    }
}
